package com.iwinding.ladygg.ui.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.iwinding.ladygg.R;

/**
 * Created by hezhiyong on 2017/4/20.
 */

public class BottomWindowView extends LinearLayout implements View.OnClickListener {

    TextView one;
    TextView two;
    TextView three;
    PopupWindow pop;

    public OnClick onClick;

    public BottomWindowView(Context context) {
        super(context);
        initView(context);
    }

    public BottomWindowView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public BottomWindowView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    public void setOnClick(OnClick onClick) {
        this.onClick = onClick;
    }

    public void setPop(PopupWindow pop) {
        this.pop = pop;
    }

    void initView(Context context) {
        View.inflate(context, R.layout.icane_view_bottom_window, this);
        one = (TextView) findViewById(R.id.text_one);
        two = (TextView) findViewById(R.id.text_two);
        three = (TextView) findViewById(R.id.text_three);

        one.setOnClickListener(this);
        two.setOnClickListener(this);
        three.setOnClickListener(this);
    }

    public void setText(String up, String mid, String down) {
        one.setText(up);
        two.setText(mid);
        three.setText(down);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.text_one:
                onClick.onClickUp();
                break;
            case R.id.text_two:
                onClick.onClickMid();
                break;
            case R.id.text_three:
                onClick.onClickDown();
                break;
        }
    }

    public interface OnClick {
        public void onClickUp();

        public void onClickMid();

        public void onClickDown();
    }

}
